package com.nl.gen.core;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * 数据层模版支持 mybatis.
 *
 * @author zenghao
 */
@Getter
@AllArgsConstructor
public enum CategoryEnum {

    MYBATIS("mybatis");

    private final String value;

    /**
     * 校验配置的类型是否支持，若不支持则使用 mybatis.
     *
     * @param category 用户传入的类型
     * @return String
     */
    public static String check(final String category) {
        boolean has = Stream.of(CategoryEnum.values()).anyMatch(e -> e.getValue().equalsIgnoreCase(category));
        return has ? category : MYBATIS.getValue();
    }
}
